<?php
/**
 * This file is part of League of Legends PHP Inibin Parser.
 *
 * League of Legends PHP Inibin Parser is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * League of Legends PHP Inibin Parser is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with League of Legends PHP Inibin Parser.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * League of Legends Client-Database parser
 *
 * @author Marcel Klimek <klimek@secondred.de>
 * @copyright Marcel Klimek
 * @version $Id: index.php 3 2011-11-12 10:07:44Z naffto88@gmail.com $
 */

error_reporting(E_ALL);
require_once('lib/class.sql.php');
require_once('lib/class.general.php');
require_once('lib/class.inibin.parser.php');
require_once('wrapper/class.champion.php');

//go through every champion directory and search for the *.inibin files
$objGeneral = new general();
//chardata is the folder, where all *.inibin files are stored
$arrFiles = $objGeneral->recursiveDir("chardata", ".inibin", ChampionEnum::$CHAMPION_MAPPING_NAME);


//uncomment for debugging the filepathes for every champion

/*foreach (ChampionEnum::$CHAMPION_MAPPING_NAME AS $key => $val)
{
    if (!array_key_exists($val, $arrFiles))
              echo $val . '<br/>';
}*/


//uncomment for debugging an single champion detailed

/*$objParser = new parser();
echo '<br/>Filename: ' . $strFilename . '<br/>';
$objSQL = new mysql();
$objParser->setDebug(true);
$objParser->loadFile("chardata/0.0.0.48/DATA/Characters/DrMundo/DrMundo.inibin");
$objChampion = new champion($objParser,$objSQL);
$objChampion->getOutput();*/



$objSQL = new mysql();
$objSQL->connect('localhost','username','password','database');
$objParser = new parser();
$i = 0;
foreach ($arrFiles AS $key => $strFilename)
{
    echo '<br/>Filename: ' . $strFilename . '<br/>';
    $objParser->loadFile($strFilename);
    $objChampion = new champion($objParser,$objSQL);
    $objChampion->getOutput();
    
    $i++;
}
echo 'files parsed: ' . $i;
?>

